package com.huaxin.device.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huaxin.device.dto.ResponseResult;
import com.huaxin.device.dto.request.AddDeviceZoneReqDTO;
import com.huaxin.device.dto.request.UpdateDeviceZoneReqDTO;
import com.huaxin.device.models.DeviceZone;
import com.huaxin.device.service.DeviceZoneService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@Tag(name = "设备区域")
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/device/deviceZone")
public class DeviceZoneController {
    private final DeviceZoneService deviceZoneService;

    /**
     * 添加设备区域
     *
     * @param in 添加设备区域参数
     * @return
     */
    @Operation(summary = "添加设备区域", description = "添加设备区域")
    @PostMapping("/addDeviceZone")
    public ResponseResult<String> addDeviceZone(@RequestBody AddDeviceZoneReqDTO in) {
        return deviceZoneService.addDeviceZone(in);
    }

    /**
     * 删除设备区域
     *
     * @param id 设备区域ID
     * @return
     */
    @Operation(summary = "删除设备区域", description = "删除设备区域")
    @GetMapping("/deleteDeviceZone")
    public ResponseResult<String> deleteDeviceZone(@Parameter(description = "设备区域ID", name = "id", required = true) @RequestParam(name = "id", required = true) String id) {
        return deviceZoneService.deleteDeviceZone(id);
    }

    /**
     * 修改设备区域
     *
     * @param in 修改设备区域参数
     * @return
     */
    @Operation(summary = "修改设备区域", description = "修改设备区域")
    @PostMapping("/updateDeviceZone")
    public ResponseResult<String> updateDeviceZone(@RequestBody UpdateDeviceZoneReqDTO in) {
        return deviceZoneService.updateDeviceZone(in);
    }

    /**
     * 查询设备区域
     *
     * @param id 设备区域ID
     * @return
     */
    @Operation(summary = "查询设备区域", description = "查询设备区域")
    @GetMapping("/queryDeviceZone")
    public ResponseResult<DeviceZone> queryDeviceZone(@Parameter(description = "设备区域ID", name = "id", required = true) @RequestParam(name = "id", required = true) String id) {
        return deviceZoneService.queryDeviceZone(id);
    }

    /**
     * 查询设备区域列表
     *
     * @param pageNum    页码
     * @param pageSize   每页数量
     * @param customerId 客户ID
     * @return
     */
    @Operation(summary = "查询设备区域列表", description = "查询设备区域列表")
    @GetMapping("/queryDeviceZoneList")
    public ResponseResult<Page<DeviceZone>> queryDeviceZoneList(@Parameter(description = "页码", name = "pageNum", required = true) @RequestParam(name = "pageNum", required = true) Integer pageNum,
                                                                @Parameter(description = "每页数量", name = "pageSize", required = true) @RequestParam(name = "pageSize", required = true) Integer pageSize,
                                                                @Parameter(description = "客户ID", name = "customerId", required = true) @RequestParam(name = "customerId", required = true) String customerId) {
        return deviceZoneService.queryDeviceZoneList(pageNum, pageSize, customerId);
    }
}
